﻿using UnityEngine;

namespace huqiang.Render
{
    public struct Shift
    {
        public Vector3 Position;
        public Vector3 Scale;
        public Quaternion Rotation;
        public static void Mul(ref Shift l, ref Shift r)
        {
            Vector3 v;
            v.x = r.Position.x * l.Scale.x;
            v.y = r.Position.y * l.Scale.y;
            v.z = r.Position.z * l.Scale.z;
            l.Position += l.Rotation * v;
            l.Rotation *= r.Rotation;
            l.Scale.x *= r.Scale.x;
            l.Scale.y *= r.Scale.y;
            l.Scale.z *= r.Scale.z;
        }
        public static Shift operator *(Shift l, Shift r)
        {
            r.Position.x *= l.Scale.x;
            r.Position.y *= l.Scale.y;
            r.Position.z *= l.Scale.z;
            l.Position += l.Rotation * r.Position;
            l.Rotation *= r.Rotation;
            l.Scale.x *= r.Scale.x;
            l.Scale.y *= r.Scale.y;
            l.Scale.z *= r.Scale.z;
            return l;
        }
    }
}
